package com.belf.web.controller.console.group;

import com.belf.common.annotation.Log;
import com.belf.common.core.controller.BaseController;
import com.belf.common.core.domain.AjaxResult;
import com.belf.common.core.page.TableDataInfo;
import com.belf.common.enums.BusinessType;
import com.belf.common.utils.poi.ExcelUtil;
import com.belf.console.service.IDataReportObjectService;
import com.belf.console.domain.DataReportObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 迁移报告对象详情Controller
 * 
 * @author belf
 * @date 2024-08-21
 */
@RestController
@RequestMapping("/console/DataReportObject")
public class DataReportObjectController extends BaseController
{
    @Autowired
    private IDataReportObjectService dataReportObjectService;

    /**
     * 查询迁移报告对象详情列表
     */
    @PreAuthorize("@ss.hasPermi('console:DataReportObject:list')")
    @GetMapping("/list")
    public TableDataInfo list(DataReportObject dataReportObject)
    {
        startPage();
        List<DataReportObject> list = dataReportObjectService.selectDataReportObjectList(dataReportObject);
        return getDataTable(list);
    }

    /**
     * 导出迁移报告对象详情列表
     */
    @PreAuthorize("@ss.hasPermi('console:DataReportObject:export')")
    @Log(title = "迁移报告对象详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataReportObject dataReportObject)
    {
        List<DataReportObject> list = dataReportObjectService.selectDataReportObjectList(dataReportObject);
        ExcelUtil<DataReportObject> util = new ExcelUtil<DataReportObject>(DataReportObject.class);
        util.exportExcel(response, list, "迁移报告对象详情数据");
    }

    /**
     * 获取迁移报告对象详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('console:DataReportObject:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dataReportObjectService.selectDataReportObjectById(id));
    }

    /**
     * 新增迁移报告对象详情
     */
    @PreAuthorize("@ss.hasPermi('console:DataReportObject:add')")
    @Log(title = "迁移报告对象详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataReportObject dataReportObject)
    {
        return toAjax(dataReportObjectService.insertDataReportObject(dataReportObject));
    }

    /**
     * 修改迁移报告对象详情
     */
    @PreAuthorize("@ss.hasPermi('console:DataReportObject:edit')")
    @Log(title = "迁移报告对象详情", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult edit(@RequestBody DataReportObject dataReportObject)
    {
        return toAjax(dataReportObjectService.updateDataReportObject(dataReportObject));
    }

    /**
     * 删除迁移报告对象详情
     */
    @PreAuthorize("@ss.hasPermi('console:DataReportObject:remove')")
    @Log(title = "迁移报告对象详情", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    public AjaxResult remove(@RequestBody DataReportObject dataReportObject)
    {
        return toAjax(dataReportObjectService.deleteDataReportObjectByIds(dataReportObject.getIdArray()));
    }
}
